Skip to content

[test] Add grammar rejection cases - #2354

Merged
rossberg merged 7 commits into
WebAssembly:mainfrom
WasmEdge:test-grammar-rejections
Nov 26, 2026
Merged

rossberg merged 7 commits into
WebAssembly:mainfrom
WasmEdge:test-grammar-rejections

Conversation

@ibmibmibm

Copy link
Copy Markdown
Contributor

Adds malformed cases for grammar rules that no test checks: bad local declarations, a bad type use, an export with two indices, br_table with no label, a stray or second else, a stray end, an elem segment with no list, duplicate elem and data ids, and a store lane index before the memarg, with and without a memory index. One commit per rule.

The store lane cases are added through simd/meta/simd_store_lane.py.

A type use has at most one (type x) clause, and that clause holds
exactly one type index. Add cases with two clauses, two indices, an
extra field, and no index.
A local with an id declares exactly one value type. Add cases with no
type and with two ids.
The else and end keywords belong to block instructions, and an if has
at most one else. Add cases with a second else, and with an else or an
end that has no open block, in plain and folded form.
An export names exactly one index, and br_table needs at least one
label. Add a case for each, in plain and folded form for br_table.
Every elem segment form needs an element list, which starts with a
reference type or func. Add cases for the passive, declarative and
active forms without one.
The ids of elem segments and data segments must be distinct, as for
other index spaces.
The lane index of v128.storeN_lane comes after the memarg. Add cases
that put it before the memarg, with and without a memory index. The
cases come from simd/meta/simd_store_lane.py.
@ibmibmibm
ibmibmibm marked this pull request as ready for review November 25, 2026 23:25
@rossberg
rossberg merged commit 1fc05ce into WebAssembly:main Nov 26, 2026
2 checks passed
@ibmibmibm
ibmibmibm deleted the test-grammar-rejections branch November 26, 2026 11:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants